package src;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import java.awt.Toolkit;

public class Dni extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JTextField textoDni;
	private JPasswordField textoPass;
	private JLabel lblContrasea;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			Dni dialog = new Dni();
			//dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Dni() {
		setTitle("Ingreso");
		
		setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\rantonana\\Documents\\prueba\\iconoSystel.png"));
		setBounds(100, 100, 703, 473);
		setResizable(false);
		getContentPane().setLayout(new BorderLayout());
		//setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		contentPanel.setBackground(new Color(204, 204, 204));
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		setModal(true);
		JLabel lblIngreseSuDni = new JLabel("Documento");
		lblIngreseSuDni.setHorizontalAlignment(SwingConstants.LEFT);
		lblIngreseSuDni.setFont(new Font("Tahoma", Font.PLAIN, 40));
		lblIngreseSuDni.setBounds(10, 84, 225, 60);
		contentPanel.add(lblIngreseSuDni);
		
		textoDni = new JTextField();
		textoDni.setFont(new Font("Tahoma", Font.PLAIN, 40));
		textoDni.setColumns(10);
		textoDni.setBounds(241, 81, 434, 67);
		
		textoDni.addActionListener(	new ActionListener() {

	        @Override
	        public void actionPerformed(ActionEvent arg0) {
	            // Se transfiere el foco al siguiente elemento.
	            ((JTextField) arg0.getSource()).transferFocus();
	        }
	    });
		
		contentPanel.add(textoDni);
		
		final JButton btnDniAceptar = new JButton("");
		btnDniAceptar.setFocusable(true);
		btnDniAceptar.setContentAreaFilled(false);
		btnDniAceptar.setBorderPainted(false);
		btnDniAceptar.setBorder(null);
		btnDniAceptar.setBounds(158, 314, 374, 100);
		btnDniAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/LoginAzulGrande.png")));
		btnDniAceptar.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/LoginBlancoGrande.png")));
		btnDniAceptar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			dispose();
			}
		});
		btnDniAceptar.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent arg0) {
				btnDniAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/LoginVerdeGrande.png")));
				getRootPane().setDefaultButton(btnDniAceptar);
				
			}
			@Override
			public void mouseExited(MouseEvent e) {
				btnDniAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/LoginAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		btnDniAceptar.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent arg0) {
				btnDniAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/LoginVerdeGrande.png")));
				getRootPane().setDefaultButton(btnDniAceptar);
			}
			@Override
			public void focusLost(FocusEvent e) {
				btnDniAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/LoginAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		
		contentPanel.add(btnDniAceptar);
		
		textoPass = new JPasswordField();
		textoPass.setFont(new Font("Tahoma", Font.PLAIN, 40));
		textoPass.setColumns(10);
		textoPass.setBounds(241, 172, 434, 67);
		
		textoPass.addActionListener(	new ActionListener() {

	        @Override
	        public void actionPerformed(ActionEvent arg0) {
	            // Se transfiere el foco al siguiente elemento.
	            ((JTextField) arg0.getSource()).transferFocus();
	        }
	    });
		contentPanel.add(textoPass);
		
		lblContrasea = new JLabel("Contrase\u00F1a");
		lblContrasea.setHorizontalAlignment(SwingConstants.LEFT);
		lblContrasea.setFont(new Font("Tahoma", Font.PLAIN, 40));
		lblContrasea.setBounds(10, 179, 225, 60);
		contentPanel.add(lblContrasea);
	}
	
	
}
